home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 22 code / PCI Driver Sample / NCR_DriverProject / Src / NameRegistryUtilities.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-08  |  2.5 KB  |  77 lines  |  [TEXT/MPCC]

  1. /*                                    NameRegistryUtilities.c                            */
  2. /*
  3.  * NameRegistryUtilities.c
  4.  * Copyright © 1994 Apple Computer Inc. All rights reserved.
  5.  *
  6.  */
  7. /*    .___________________________________________________________________________________.
  8.       | These functions manage low-level access to the Name Registry. Because they        |
  9.       | allocate memory, they must be called from the driver initialization functions.    |
  10.     .___________________________________________________________________________________.
  11. */
  12.  
  13. #include "NCRDriverPrivate.h" 
  14.  
  15.  
  16. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  17.  * This is a generic function that retrieves a property from the Name Registry,
  18.  * allocating memory for it in the system pool. It looks in the Name Registry entry
  19.  * for this driver -- the DriverInitializeCmd passed this as one of its parameters.
  20.  * This sample is specific to device drivers: it allocates the property in the resident
  21.  * memory pool.
  22.  */
  23. OSErr
  24. GetThisProperty(
  25.         RegEntryIDPtr            regEntryIDPtr,            /* Driver's Name Registery ID    */
  26.         RegPropertyNamePtr        regPropertyName,
  27.         RegPropertyValue        **regPropertyValuePtr,
  28.         RegPropertyValueSize    *regPropertyValueSizePtr
  29.     )
  30. {
  31.         OSErr                    status;
  32.  
  33.         Trace(GetThisProperty);
  34.         /*
  35.          * In addition to getting the size of a property, this function will fail if
  36.          * the property is not present in the registry. We NULL the result before
  37.          * starting so we can dispose of the property even if this function failed.
  38.          */
  39.         *regPropertyValuePtr = NULL;
  40.         status = RegistryPropertyGetSize(
  41.                     regEntryIDPtr,
  42.                     regPropertyName,
  43.                     regPropertyValueSizePtr
  44.                 );
  45.         //** CheckStatus(status, "\pRegistryPropertyGetSize failed");
  46.         if (status == noErr) {
  47.             *regPropertyValuePtr = (RegPropertyValue *)
  48.                         PoolAllocateResident(*regPropertyValueSizePtr, FALSE);
  49.             status = RegistryPropertyGet(
  50.                         regEntryIDPtr,
  51.                         regPropertyName,
  52.                         *regPropertyValuePtr,
  53.                         regPropertyValueSizePtr
  54.                     );
  55.             CheckStatus(status, "\pRegistryPropertyGet failed");
  56.         }
  57.         return (status);
  58. }
  59.  
  60. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  61.  * Dispose of a property that was obtained by calling GetThisProperty(). This sample is
  62.  * specific to device drivers: the property was allocated in the resident memory pool.
  63.  */
  64. void
  65. DisposeThisProperty(
  66.         RegPropertyValue        *regPropertyValuePtr
  67.     )
  68. {
  69.         Trace(DisposeThisProperty);
  70.         if (*regPropertyValuePtr != NULL) {
  71.             PoolDeallocate(*regPropertyValuePtr);
  72.             *regPropertyValuePtr = NULL;
  73.         }
  74. }
  75.  
  76.  
  77.